package com.gitee.service;

import com.gitee.bridge.abs.AbstractRegisterLoginComponent;
import com.gitee.bridge.function.factory.RegisterLoginComponentFactory;
import com.gitee.pojo.UserInfo;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户登录  第三方登录 桥接模式
 *
 * @author acao
 * @since 2023-11-06 09:56
 */
@Service
public class UserBridgeService {

    /**
     * 用户登录
     *
     * @param account  账号
     * @param password 密码
     */
    public String login(String account, String password) {
        AbstractRegisterLoginComponent component = RegisterLoginComponentFactory.getComponent("Default");
        return component.login(account, password);
    }

    /**
     * 用户注册
     *
     * @param userInfo userinfo
     */
    public String register(UserInfo userInfo) {
        AbstractRegisterLoginComponent component = RegisterLoginComponentFactory.getComponent("Default");
        return component.register(userInfo);
    }

    /**
     * 第三方登录回调地址
     */
    public String login3rd(HttpServletRequest request, String type) {
        AbstractRegisterLoginComponent component =
                RegisterLoginComponentFactory.getComponent(type);
        return component.login3rd(request);
    }
}
